package com.flying.acls.dao;

import com.flying.acls.model.Resource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;

import java.util.List;

public interface ResourceRepository extends JpaRepository<Resource, Long>, QuerydslPredicateExecutor<Resource> {
    @PostAuthorize("hasPermission(returnObject, 'READ')")
    Resource findTopById(Long id);

    @PreAuthorize("authenticated")
    List<Resource> findAll();
}
